import { Component, OnInit, Input } from '@angular/core'
import { Task, ETaskPostRiskOperation } from '@shared/interfaces/task'
import { PostRiskScheme } from '@shared/interfaces/post-risk-control'
import { PostRiskStoreService } from '../../../../post-risk/new/post-risk-store.service'

@Component({
  selector: 'app-post-risk',
  templateUrl: './post-risk.component.html',
  styles: [],
})
export class PostRiskComponent implements OnInit {
  @Input() task: Task
  isNeedDiff: Boolean
  ETaskPostRiskOperation = ETaskPostRiskOperation
  postRiskFull: PostRiskScheme
  origPostRiskFull: PostRiskScheme
  constructor(private riskStore: PostRiskStoreService) {}

  ngOnInit() {
    this.postRiskFull = this.task.data.postRiskSchemeData
    this.origPostRiskFull = this.task.data.origPostRiskSchemeData
    this.isNeedDiff = this.checkUpdateOperation(this.task.operation)
  }

  checkUpdateOperation(type: string): Boolean {
    if (type === this.ETaskPostRiskOperation.UpdatePostRisk) {
      return true
    }
    return false
  }
}
